package com.swj.common.core.remoteService.fallback;

import com.swj.common.core.model.SysLoginLog;
import com.swj.common.core.model.SysOperaLog;
import com.swj.common.core.remoteService.RemoteLogService;
import com.swj.common.core.utils.ResponseUtil;
import com.swj.common.core.model.web.RestResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 日志服务降级处理
 * 
 * @author ruoyi
 */
@Component
@Slf4j
public class RemoteLogFallbackFactory implements FallbackFactory<RemoteLogService> {

    @Override
    public RemoteLogService create(Throwable throwable) {

        log.error("日志服务调用失败:{}", throwable.getMessage());
        return new RemoteLogService() {
            @Override
            public RestResult add(SysOperaLog operLog, String source) {
                return ResponseUtil.fail("失败");
            }

            @Override
            public RestResult<Boolean> saveLogininfor(SysLoginLog sysLogininfor, String source) {
                return ResponseUtil.fail("失败");
            }


        };

    }
}
